var t = getApp();

Page({
    data: {
        page: 1
    },
    onLoad: function(t) {
        t.store_id && this.setData({
            store_id: t.store_id
        });
        var e = wx.getStorageSync("yz_basic_info");
        e && (this.setData({
            appointmentLang: e.lang.appointment
        }), wx.setNavigationBarTitle({
            title: "门店".concat(e.lang.appointment.worker)
        })), this.getTechnician();
    },
    deleteItem: function(e) {
        var a = this, n = e.currentTarget.dataset.item.id, o = t.getNetAddresss("plugin.appointment.frontend.worker.delete-worker");
        t._postNetWork({
            url: o,
            data: {
                worker_id: n
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                }), a.getTechnician()) : (wx.showToast({
                    title: e.msg,
                    icon: "none"
                }), console.log(e.msg));
            }
        });
    },
    toAdd: function(t) {
        if (console.log(t), t.currentTarget.dataset.bj) {
            var e = t.currentTarget.dataset.item.store_id, a = t.currentTarget.dataset.item.id;
            wx.navigateTo({
                url: "/packageE/appointment/manager/add_technician?store_id=" + e + "&worker_id=" + a
            });
        } else wx.navigateTo({
            url: "/packageE/appointment/manager/add_technician?store_id=" + this.data.store_id
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getTechnician();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) console.log("没有更多"); else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.MoreGetTechnician();
        }
    },
    onShareAppMessage: function() {},
    getTechnician: function() {
        var e = this, a = t.getNetAddresss("plugin.appointment.frontend.worker.get-list-by-store-id");
        t._postNetWork({
            url: a,
            data: {
                store_id: e.data.store_id,
                page: e.data.page
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (console.log(a), e.setData({
                    technicianList: a.data.data,
                    current_page: a.data.current_page,
                    last_page: a.data.last_page
                })) : (wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg));
            }
        });
    },
    MoreGetTechnician: function() {
        var e = this, a = t.getNetAddresss("plugin.appointment.frontend.worker.get-list-by-store-id");
        t._postNetWork({
            url: a,
            data: {
                store_id: e.data.store_id,
                page: e.data.page
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (console.log(a), e.setData({
                    technicianList: a.data.data,
                    current_page: a.data.current_page,
                    last_page: a.data.last_page
                })) : (wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg));
            }
        });
    }
});